Data specifics

  • The Longitudinal Employer Household Dynamics (LEHD) program at the US Census Bureau releases the Origin Destination Employment Statistis (LODES) datasets annually based on employer-employee insurance records.
  • This datafile uses data from the Origin-Destination (OD) data files from LEHD. The OD datafile lists each pair the census blocks for where workers live and work, enabling us to calculate the average commute distance by calculating the distance between each home and workplace census block pairing.
  • Distance calculations: All distances are “as the crow flies” and calulated using the Vincenty Ellipsoid method based on the latitude and longitudes of the centroids of each census block. These distances are then aggregated to the census block group and tract level.
  • Data presented here are from 2018 and spatial units are based on the 2010 census. As of July of 2021, 2018 is the most recent year for which data are available. The earliest year for which data are available is 2002.
  • The data contains average and median commute distances for each SU calculated based on the following groups: (1) People who live and work in the Eastern Shore region; (2) Eastern Shore residents who work within 40 miles of their home census block; (3) Eastern Shore residents who work in a tract outside the Eastern Shore that employs at least 25 Eastern Shore residents; (4) All Eastern Shore area residents represented in the LODES OD data. The data also contains the number of residents within each SU who fall into those 4 categories.
  • Some limitations:
    • The data are prone to imperfect geocoding for certain jobs; jobs for companies with multiple branches are often all coded in the same location. This means that distance calculations are likely to be an overestimate if many residents within one SU are employed by a company with multiple branches or a company whose headquarters is far away. There is also no way to differentiate between remote workers or the frequency with which any worker actually travels to their place of emplyoment (though note: these data were collected prior to the COVID-19 pandemic when fewer people were working remotely). For these reasons, we include calculations of average and median commute distances based on multiple groups of workers. The estimates based on all residents in an SU are most likely to be an overestimate, while those based on residents working within 40 miles of home are likely to be the most conservative.
    • The distances are “as the crow flies” and therefore imprecise estimates of actual commute distances on the road.
    • These data do not include workers in defense-related industries.
    • Student-workers are unlikely to be represented in these data because their jobs are not typically covered by state unemployment insurance.

Variable Descriptions

Eastern Shore Area Residents

glimpse(lodesresidents_blkgp)
## Rows: 43
## Columns: 15
## $ blkgroup             <dbl> 510010901001, 510010901002, 510010901003, 5100109…
## $ medc_allblk          <dbl> 45.87512, 45.43606, 37.65439, 41.07406, 43.54075,…
## $ medc_workinRegionblk <dbl> 8.998906, 7.036666, 8.178206, 8.454102, 8.173306,…
## $ medc_within40blk     <dbl> 8.370839, 6.173518, 7.641535, 6.434638, 8.382186,…
## $ medc_25_employeesblk <dbl> 13.525101, 18.134192, 21.045550, 11.301578, 19.61…
## $ commutersInBlgr      <int> 429, 370, 288, 261, 263, 972, 657, 276, 285, 339,…
## $ commuterinRegionblk  <int> 298, 250, 205, 180, 168, 647, 432, 156, 167, 202,…
## $ commuterw40blk       <int> 291, 248, 202, 176, 170, 643, 437, 163, 173, 210,…
## $ commuter25blk        <int> 323, 286, 234, 202, 201, 746, 492, 177, 196, 233,…
## $ avgc_allblk          <dbl> 45.60011, 44.03670, 39.39414, 42.69355, 45.55925,…
## $ avgc_workinRegionblk <dbl> 9.695082, 7.122045, 8.307257, 8.208582, 8.390502,…
## $ avgc_within40blk     <dbl> 8.820367, 6.808916, 7.761259, 7.403881, 8.730307,…
## $ avgc_25_employeesblk <dbl> 16.67561, 18.71414, 18.45512, 19.53141, 22.44348,…
## $ county               <int> 51001, 51001, 51001, 51001, 51001, 51001, 51001, …
## $ GEOID                <chr> "510010901001", "510010901002", "510010901003", "…
metaresidents %>% 
  filter(su_blkgp == 1) %>%
  select(varname, about) %>% as.list()
## $varname
##  [1] "blkgroup"             "county"               "avgc_allblk"         
##  [4] "medc_allblk"          "commutersInBlgr"      "avgc_within40blk"    
##  [7] "medc_within40blk"     "commuterw40blk"       "avgc_25_employeesblk"
## [10] "medc_25_employeesblk" "commuter25blk"        "avgc_workinRegionblk"
## [13] "medc_workinRegionblk" "commuterinRegionblk" 
## 
## $about
##  [1] "12-digit census block group code"                                                                                                                                                     
##  [2] "5-digit county code"                                                                                                                                                                  
##  [3] "Average \"as the crow flies\" commuting distance for all residents of the census block group"                                                                                         
##  [4] "Median \"as the crow flies\" commuting distance for all residents of the census block group"                                                                                          
##  [5] "The number of residents in each census block group who are represented in the data"                                                                                                   
##  [6] "Average \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"                                                                    
##  [7] "Median \"as the crow flies\" commuting distance for residents of the census block group who work within 40 miles"                                                                     
##  [8] "The number of residents in the census block group who work within 40 miles of home"                                                                                                   
##  [9] "Average \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents from the region of interest"
## [10] "Median \"as the crow flies\" commuting distance for residents of the census block group who commute to a census tract that employs at least 25 residents of the region of interest"   
## [11] "The number of residents in the census block group who commute to a census tract that employs at least 25 residents of the region of interest"                                         
## [12] "Average \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"                                              
## [13] "Median \"as the crow flies\" commuting distance for residents of the census block group who work in the same region as where they live"                                               
## [14] "The number of residents in the census block group who commute to work within the region of interest"

Eastern Shore Area Workers

glimpse(lodesworkers_blkgp)
## Rows: 43
## Columns: 16
## $ blkgroup                            <dbl> 510010901001, 510010901002, 510010…
## $ medc_allworkersblkgr                <dbl> 14.653191, 14.067786, 14.683464, 1…
## $ medc_livewithin40blkgr              <dbl> 5.720533, 4.908061, 6.427316, 6.26…
## $ medc_25_resblkgr                    <dbl> 6.612876, 4.908061, 6.427316, 6.95…
## $ workersInblkgr                      <int> 452, 192, 147, 122, 128, 399, 1447…
## $ liveoutsideRegionblkgr              <int> 33, 18, 9, 11, 53, 131, 425, 4, 2,…
## $ liveinsideRegionblkgr               <int> 419, 174, 138, 111, 75, 268, 1022,…
## $ perc_workers_liveinRegionblkgr      <dbl> 92.69912, 90.62500, 93.87755, 90.9…
## $ perc_workers_liveoutsideRegionblkgr <dbl> 7.300885, 9.375000, 6.122449, 9.01…
## $ workersw40blkgr                     <int> 411, 173, 138, 110, 75, 269, 1030,…
## $ workers25blkgr                      <int> 417, 173, 138, 111, 75, 268, 1020,…
## $ avgc_allworkersblkgr                <dbl> 15.101568, 16.681547, 14.584871, 1…
## $ avgc_livewithin40blkgr              <dbl> 5.785433, 5.014835, 6.337034, 5.95…
## $ avgc_25_resblkgr                    <dbl> 6.524076, 5.240530, 6.337034, 6.27…
## $ county                              <int> 51001, 51001, 51001, 51001, 51001,…
## $ GEOID                               <chr> "510010901001", "510010901002", "5…
metaworkers %>% 
  filter(su_blkgp == 1) %>%
  select(varname, about) %>% as.list()
## $varname
##  [1] "blkgroup"                            "medc_allworkersblkgr"               
##  [3] "medc_livewithin40blkgr"              "medc_25_resblkgr"                   
##  [5] "workersInblkgr"                      "liveoutsideRegionblkgr"             
##  [7] "liveinsideRegionblkgr"               "perc_workers_liveinRegionblkgr"     
##  [9] "perc_workers_liveoutsideRegionblkgr" "workersw40blkgr"                    
## [11] "workers25blkgr"                      "avgc_allworkersblkgr"               
## [13] "avgc_livewithin40blkgr"              "avgc_25_resblkgr"                   
## [15] "county"                             
## 
## $about
##  [1] "12-digit census block group code where the workers are employed (workplace census block group)"                                                                 
##  [2] "Median \"as the crow flies\" commuting distance for all workers employed in the census block group"                                                             
##  [3] "Median \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"                                
##  [4] "Median \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live" 
##  [5] "The total number of workers employed in the census block group"                                                                                                 
##  [6] "The number of workers employed in the census block group that live outside the region of interest"                                                              
##  [7] "The number of workers employed in the census block group who live outside the region of interest"                                                               
##  [8] "The percent of workers employed in the census block group who live inside the region of interest"                                                               
##  [9] "The percent of workers employed in the census block group who live outside the region of interest"                                                              
## [10] "The number of workers employed in the census block group who live within 40 miles of work"                                                                      
## [11] "The number of workers employed in the census block group who live in a census tract where at least 25 region of interest workers live"                          
## [12] "Average \"as the crow flies\" commuting distance for all workers employed in the census block group"                                                            
## [13] "Average \"as the crow flies\" commuting distance for workers employed in the census block group who live within 40 miles of work"                               
## [14] "Average \"as the crow flies\" commute for workers employed in the census block group who live in census tract where at least 25 region of interest workers live"
## [15] "5-digit county code"

Variable Summaries

Eastern Shore Area Residents

lodesresidents_blkgp %>% select(avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk) %>% 
  select(where(~is.numeric(.x))) %>% 
  as.data.frame() %>% 
  stargazer(., type = "text", title = "Summary Statistics", digits = 1,
            summary.stat = c("mean", "sd", "min", "median", "max"))
## 
## Summary Statistics
## ====================================================
## Statistic            Mean St. Dev. Min  Median  Max 
## ----------------------------------------------------
## avgc_allblk          44.4   13.7   29.6  42.7  106.1
## avgc_within40blk     10.1   3.4    6.8   9.4   22.3 
## avgc_25_employeesblk 18.6   10.9   9.6   16.5  67.0 
## avgc_workinRegionblk 8.3    3.2    5.1   7.6   20.2 
## medc_allblk          41.9   14.3   24.7  38.7  104.3
## medc_within40blk     10.0   3.9    5.5   9.1   24.0 
## medc_25_employeesblk 16.0   11.1   7.9   13.6  63.3 
## medc_workinRegionblk 8.3    3.7    4.6   7.4   24.0 
## ----------------------------------------------------

Eastern Shore Area Workers

lodesworkers_blkgp %>% select(avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr, perc_workers_liveoutsideRegionblkgr) %>% 
  select(where(~is.numeric(.x))) %>% 
  as.data.frame() %>% 
  stargazer(., type = "text", title = "Summary Statistics", digits = 1,
            summary.stat = c("mean", "sd", "min", "median", "max"))
## 
## Summary Statistics
## =================================================================
## Statistic                           Mean St. Dev. Min Median Max 
## -----------------------------------------------------------------
## avgc_allworkersblkgr                27.1   10.9   9.0  24.1  51.4
## avgc_livewithin40blkgr              8.9    2.8    5.0  8.9   24.6
## avgc_25_resblkgr                    7.9    2.6    5.2  7.3   22.4
## medc_allworkersblkgr                26.6   12.8   6.9  24.8  59.3
## medc_livewithin40blkgr              9.0    2.9    4.9  8.8   24.1
## medc_25_resblkgr                    8.1    2.8    4.9  7.6   22.2
## perc_workers_liveoutsideRegionblkgr 21.7   10.2   0.0  21.5  41.4
## -----------------------------------------------------------------

Visual Distributions

Eastern Shore Area Residents

By Tracts

longr <- lodesresidents_tract %>% select(c(tract, avgc_alltr, avgc_within40tr, avgc_25_employeestr, avgc_workinRegiontr, medc_alltr, medc_within40tr, medc_25_employeestr, medc_workinRegiontr)) %>% 
  pivot_longer(-tract, names_to = "measure", values_to = "value")

longr$measure <- factor(longr$measure,
                         levels = c("avgc_alltr", "medc_alltr", "avgc_within40tr", "medc_within40tr", "avgc_25_employeestr", "medc_25_employeestr", "avgc_workinRegiontr",
                                    "medc_workinRegiontr"))

longr %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

By Block Groups

longr <- lodesresidents_blkgp %>% select(c(blkgroup, avgc_allblk, avgc_within40blk, avgc_25_employeesblk, avgc_workinRegionblk, medc_allblk, medc_within40blk, medc_25_employeesblk, medc_workinRegionblk)) %>% 
  pivot_longer(-blkgroup, names_to = "measure", values_to = "value")

longr$measure <- factor(longr$measure,
                         levels = c("avgc_allblk", "medc_allblk", "avgc_within40blk", "medc_within40blk", "avgc_25_employeesblk", "medc_25_employeesblk", "avgc_workinRegionblk",
                                    "medc_workinRegionblk"))

longr %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

By Blocks

longr <- lodesresidents_block %>% select(c(h_geocode, avgc_all, avgc_within40, avgc_25_employees, avgc_workinRegion, medc_all, medc_within40, medc_25_employees, medc_workinRegion)) %>% 
  pivot_longer(-h_geocode, names_to = "measure", values_to = "value")

longr$measure <- factor(longr$measure,
                         levels = c("avgc_all", "medc_all", "avgc_within40", "medc_within40", "avgc_25_employees", "medc_25_employees", "avgc_workinRegion",
                                    "medc_workinRegion"))

longr %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

Eastern Shore Area Workers

By Tracts

longw <- lodesworkers_tract %>% select(c(tract, avgc_allworkerstr, avgc_livewithin40tr, avgc_25_restr, medc_allworkerstr, medc_livewithin40tr, medc_25_restr)) %>% 
  pivot_longer(-tract, names_to = "measure", values_to = "value")

longw$measure <- factor(longw$measure,
                         levels = c("avgc_allworkerstr", "medc_allworkerstr", "avgc_livewithin40tr", "medc_livewithin40tr", "avgc_25_restr", "medc_25_restr"))

longw %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

By Block Groups

longw <- lodesworkers_blkgp %>% select(c(blkgroup, avgc_allworkersblkgr, avgc_livewithin40blkgr, avgc_25_resblkgr, medc_allworkersblkgr, medc_livewithin40blkgr, medc_25_resblkgr)) %>% 
  pivot_longer(-blkgroup, names_to = "measure", values_to = "value")

longw$measure <- factor(longw$measure,
                         levels = c("avgc_allworkersblkgr", "medc_allworkersblkgr", "avgc_livewithin40blkgr", "medc_livewithin40blkgr", "avgc_25_resblkgr", "medc_25_resblkgr"))

longw %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

By Blocks

longw <- lodesworkers_block %>% select(c(w_geocode, avgc_allworkers, avgc_livewithin40, avgc_25_res, medc_allworkers, medc_livewithin40, medc_25_res)) %>% 
  pivot_longer(-w_geocode, names_to = "measure", values_to = "value")

longw$measure <- factor(longw$measure,
                         levels = c("avgc_allworkers", "medc_allworkers", "avgc_livewithin40", "medc_livewithin40", "avgc_25_res", "medc_25_res"))

longw %>% 
  ggplot(aes(x = value, fill = measure)) +
  scale_fill_viridis(option = "plasma", discrete = TRUE, guide = "none") +
  geom_histogram() + 
  facet_wrap(~measure, scales = "free", ncol = 2)

Mapping

All Eastern Shore area residents

Average commute distance.

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_alltr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(avgc_alltr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_tract$avgc_alltr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$avgc_alltr, 
            title = "Average commute (mi)", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_allblk)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(avgc_allblk),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_blkgp$avgc_allblk, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_allblk, 
            title = "Average commute (mi)", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.

All Eastern Shore area workers

Average commmute distance.

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = 
                      lodes_tract$avgc_allworkertr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(avgc_allworkerstr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_tract$avgc_allworkerstr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$avgc_allworkerstr, 
            title = "Average commute (mi)", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = 
                      lodes_blkgp$avgc_allworkersblkgr)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(avgc_allworkersblkgr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_blkgp$avgc_allworkersblkgr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_allworkersblkgr, 
            title = "Average commute (mi)", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.

Eastern Shore Area Residents within 40 miles

Average commute among those who work with in 40 miles of home.

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_within40tr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(avgc_within40tr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_tract$avgc_within40tr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$avgc_within40tr, 
            title = "Average commute (mi)", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_within40blk)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(avgc_within40blk),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_blkgp$avgc_within40blk, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_within40blk, 
            title = "Average commute (mi)", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.

Eastern Shore Area Workers within 40 miles

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_livewithin40tr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(avgc_livewithin40tr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_tract$avgc_livewithin40tr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$avgc_livewithin40tr, 
            title = "Average commute (mi)", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_livewithin40blkgr)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(avgc_livewithin40blkgr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_blkgp$avgc_livewithin40blkgr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_livewithin40blkgr, 
            title = "Average commute (mi)", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.

Eastern Shore Area Workers and Residents

Average commute distances for people who work and live in the Eastern Shore region.

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$avgc_workinRegiontr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(avgc_workinRegiontr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_tract$avgc_workinRegiontr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$avgc_workinRegiontr, 
            title = "Average commute (mi)", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$avgc_workinRegionblk)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(avgc_workinRegionblk),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Average commute (mi): ", round(lodes_blkgp$avgc_workinRegionblk, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$avgc_workinRegionblk, 
            title = "Average commute (mi)", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.

Eastern Shore Area Workers and Non-Residents

By Tract

pal <- colorNumeric("plasma", reverse = T, domain = lodes_tract$perc_workers_liveoutsideRegiontr)

leaflet(lodes_tract) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_tract,
              fillColor = ~pal(perc_workers_liveoutsideRegiontr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_tract$GEOID, "<br>",
                             "Percent of workers: ", round(lodes_tract$perc_workers_liveoutsideRegiontr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_tract$perc_workers_liveoutsideRegiontr, 
            title = "Percent of workers <br> who live outside <br> Eastern Shore  region", opacity = 0.7)

By Block Group

pal <- colorNumeric("plasma", reverse = T, domain = lodes_blkgp$perc_workers_liveoutsideRegionblkgr)

leaflet(lodes_blkgp) %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addPolygons(data = lodes_blkgp,
              fillColor = ~pal(perc_workers_liveoutsideRegionblkgr),
              weight = 1,
              opacity = 1,
              color = "white", 
              fillOpacity = 0.6,
              highlight = highlightOptions(
                weight = 1, fillOpacity = 0.8, bringToFront = T
              ),
              popup = paste0("GEOID: ", lodes_blkgp$GEOID, "<br>",
                             "Percent of workers: ", round(lodes_blkgp$perc_workers_liveoutsideRegionblkgr, 2))) %>% 
  addLegend("bottomright", pal = pal, values = lodes_blkgp$perc_workers_liveoutsideRegionblkgr, 
            title = "Percent of workers <br> who live outside <br> Eastern Shore  region", opacity = 0.7)

By Blocks

Block level maps are slow to render and may be added later.